<?php
////////////////////////////////////////////////////
//	LinBoard
//	login.php
//	Created: 22th February 2009; 01:31 UTC
//	LinBoard (c) Copyright OpenInferno 2008, 2009
////////////////////////////////////////////////////

//Setup Environment
error_reporting(E_ALL | E_STRICT);
define("LINBOARD", true);

//Load Framework
require_once("./Config.php");
require_once(ROOT_PATH . "/Framework/Framework.php");

if(isset($_GET['logout']))
{
	Framework::Login()->logoutUser();
	header("Location: ".Framework::Config()->Main['weburl']."/login.php");
	die();
}

if(isset($_GET['check']))
{
	if(Framework::Login()->loginUser($_POST['username'], $_POST['password']))
	{
		//Login Success, redirect user to homepage
		header("Location: ".Framework::Config()->Main['weburl']);
		die();
	} else {
		//Set error Message
		Framework::Template()->set("error", "Incorrect Username/Password Combination");
	}
}

if(Framework::Login()->checkCookie())
{
	header("Location: ".Framework::Config()->Main['weburl']);
	die();
}

Framework::Template()->fetch(ROOT_PATH . "/Templates/Default/login_template.php");
?>